package rechit;

class Rectangle {
    // x Coord of top left point
    double x;
    // y Coord of top left point
    double y;
    // width of the rectangle
    double width;
    // Height of the rectangle
    double height;
           
    // Create the Rectangle with (x,y,width,height)
    
    public Rectangle(Double x, Double y,Double width, Double height) {
        this.x = x;
        this.y = y;
        this.width = width;
        this.height = height;
    }
    
    // Functions for various corner values
    
    public double topLeftCornerX() {
        return x;
    }
    
    public double topLeftCornerY() {
        return y;
    }
    
    public double topRightCornerX() {
        return (x+width);
    }
    
    public double topRightCornerY() {
        return y;
    }
    public double bottomLeftCornerX() {
        return x;
    }
    
    public double bottomLeftCornerY() {
        return (y-height);
    }
    public double bottomRightCornerX() {
        return (x+width);
    }
    
    public double bottomRightCornerY() {
        return (y-height);
    }
    
    
    // Function that checks that a point (x,y) lies within the Rectangle
    
    public boolean checkHit(double hitx,double hity) {
        // if the hit is in between the x coords and between the y coords it must
        // hit the rectangle.
        if((hitx>=x && hitx<=(x+width)) && (hity<=y && hity>=(y-height))) return true;
        else return false;       
    }
}